<?php

declare(strict_types=1);

namespace App\Controller\Home\Drp;

use App\Controller\AbstractController;
use App\Model\Device;
use App\Model\Distributors;
use App\Model\Normal;
use App\Model\Station;
use App\Services\PushService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\Redis\Redis;
use Psr\Http\Message\ResponseInterface;
use Trait\ResponseMsg;

class PushController extends AbstractController
{
    use ResponseMsg;

    protected Redis $redis;
    protected Normal $normal;
    protected PushService $pushService;

    #[Inject]
    protected Distributors $distributors;

    #[Inject]
    protected Device $device;


    public function __construct()
    {
        $this->pushService = container()->get(PushService::class);
        $this->redis = container()->get(Redis::class);
        $this->normal = container()->get(Normal::class);
    }

    public function getCode(RequestInterface $request):ResponseInterface{
        $data['ip'] = $this->normal::getRealIp($request);
        $data['code'] =  $this->pushService->getCode();
        return $this->success($data);
    }


    public function getToken(RequestInterface $request):ResponseInterface{
        $data = $this->pushService->getToken();
        return $this->success($data);
    }


    public function sendStation(RequestInterface $request):ResponseInterface{
        $station = Station::find(6143);
        $data = $this->pushService->sendStation($station);
        return $this->success($data);
    }


    public function sendOper(RequestInterface $request):ResponseInterface{
        $distributor = Distributors::find(10);
        $data = $this->pushService->createOper($distributor);
        return $this->success($data);
    }

}
